const app = getApp(),url = app.globalData.url;
Page({

  data: {
    // 判断显示那种数据
    type_tow:1,
    // 企业数组数据
    listArr:[
      
    ],
    //职位数组数据
    listdata:[
      
    ],
    zhiwei:{
      companySize: "",
      industry: "",
      nature: "",
      pageNum: 1,
      pageSize: 910,
      positionName: "工程师",
      userUid: "",
      wageRange: "",
    },
    qiye:{
      companyName: "",
      currentPage: 1,
      industry: "",
      nature: "",
      pageSize: 936,
      size: "",
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options.sts)
    console.log(options.key)
    var that = this
    that.setData({type_tow:options.sts})//1   2
    that.search(options.key,options.sts)
  },
  search(key,sts){
    var that = this
    if(sts == 2){//2 企业
      that.data.qiye.companyName = key
      var urlapi = 'enterpriselib/getEnterpriseLibList'
      var where = that.data.qiye
      var method ='POSt'
    }else{// 1 职位
      that.data.zhiwei.positionName = key
      var urlapi = 'position/findWorkList'
      var where = that.data.zhiwei
      var method ='POST'
    }
    wx.request({
      header: {
        'content-type': 'application/json' // 默认值
      },
      url:url+ urlapi,
      method: method,
      data:where,
      success:function(res){
        console.log("搜索",res);
        var ret = res.data
        if(ret.code == 200){
          if(sts == 2){//企业
            if(ret.data.content != ''){
              var listArr=that.data.listArr.concat(ret.data.content)
              that.setData({listArr})
            }else{
              wx.showToast({
                title: '没有数据了~',
                icon:'none'
              })
              setTimeout(function(){
                wx.navigateBack({
                  delta: 1,
                })
              },1500)
            }
          }else{//职位
            if(ret.data.content != ''){
              var listdata=that.data.listdata.concat(ret.data.content)
              that.setData({listdata})
            }else{
              wx.showToast({
                title: '没有数据了~',
                icon:'none'
              })
              setTimeout(function(){
                wx.navigateBack({
                  delta: 1,
                })
              },1500)
            }
          }
          
        }else{
          wx.showToast({
            title: ret.msg,
            icon:'none'
          })
        }
      }
    })

  },
  
})